package TestController;

import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Test;
import Task28.Command;
import Task28.Controller;
import Task28.Result;

public class TestFind {
	Result result = new Result();
	Command command = new Command();
	Controller tester = new Controller();

	private void init() {
		command.setNameCommand("find");
		command.setWorkDir("C:\\TEST2");
	}

	@Test
	public void test() {
		init();
		String[] args = null;
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}

	@Test
	public void test0() {
		init();
		String[] args = { "", "" };
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(aResult.isEmpty());
	}
	
	@Test
	public void test1() {
		init();
		String[] args = { null, null };
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}

	@Test
	public void test2() {
		init();
		String[] args = { "", "", "" };
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}

	
	
	@Test
	public void test3() {
		init();
		String[] args = { "C:\\TEST2\\notExistDir", "1" };// not exist
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}

	@Test
	public void test4() {
		init();
		String[] args = { "C:\\TEST2\\1111", "1" };// exist dir
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(aResult.isEmpty());
	}

	@Test
	public void test5() {
		init();
		String[] args = { "C:\\TEST2\\proga.exe", "pro" };// exist file
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}

	@Test
	public void test6() {
		init();
		String[] args = { "C:\\TEST2\\notExist.exe", "sdf" };// not exist file
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}
	@Test
	public void test7() {
		init();
		String[] args = { "C:\\TEST2\\1111", "" };// exist dir
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(aResult.isEmpty());
	}
	
	@Test
	public void test8() {
		init();
		String[] args = { "1111", "1" };// exist dir
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(aResult.isEmpty());
	}
	
	@Test
	public void test9() {
		init();
		String[] args = { "1" };
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(aResult.isEmpty());
	}

	@Test
	public void test10() {
		init();
		String[] args = { "*" };
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(aResult.isEmpty());
	}
	@Test
	public void test11() {
		init();
		String[] args = { };
		command.setArgs(args);

		result = tester.getResult(command);
		ArrayList<String> aResult = new ArrayList<String>();
		aResult = result.getErrors();

		assertTrue(!aResult.isEmpty());
	}

}
